package com.lsa.letcode.the129.sumRootToLeaf;

import static org.junit.Assert.assertEquals;

import java.io.IOException;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;
import com.lsa.letcode.common.TreeNode;
import com.lsa.letcode.common.TreeUtils;

public class SumRootToLeafTest extends LetCodeTestBase {
	@Test
	public void test() throws Exception {
		test("1.tgf", 25);
		test("2.tgf", 124 + 135 + 136);
		test("3.tgf", 1);
		test("4.tgf", 124 + 135 + 136);
		test("5.tgf", 124 + 135);
		test("6.tgf", 12);
		test("7.tgf", 124 + 125 + 136 + 137);
	}

	private void test(String resName, int expected) throws IOException {
		Solution s = new Solution();
		TreeNode r = TreeUtils.fromTgf(this.getClass(), resName);
		assertEquals(expected, s.sumNumbers(r));
	}
}
